package com.example.hospital.service.impl;

import com.example.hospital.mapper.SystemLogMapper;
import com.example.hospital.pojo.SystemLog;
import com.example.hospital.service.SystemLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SystemLogServiceImpl implements SystemLogService {

    @Autowired
    private SystemLogMapper systemLogMapper;

    // 记录日志
    @Override
    public void logAction(SystemLog log) {
        systemLogMapper.insertLog(log);
    }

    // 获取所有日志
    @Override
    public List<SystemLog> getAllLogs() {
        return systemLogMapper.findAll();
    }

    // 获取特定用户的日志
    @Override
    public List<SystemLog> getLogsByUserId(Integer userId) {
        return systemLogMapper.findByUserId(userId);
    }
}
